stage.create_grid_overlay(50, "blue")
target = codesters.Sprite("triangle")
target.set_opacity(.5)
target.go_to(-150, 100)
target.rotate_origin(90)
text = codesters.Text("Target", -100, -175)
text.set_size(.8)
text.set_opacity(.8)
sprite = codesters.Sprite("triangle")
sprite.go_to(-150, 100)
sprite.say("Start")
try:
tval1 = sprite.get_rotation()
except:
tval1 = "DNE"
# try:
# tval2 = sprite.get_x()
# except:
# tval2 = "DNE"
try:
tval3 = sprite.get_y()
except:
tval3 = "DNE"
if tval1 == 90 and tval3 == -150:
sprite.say(" ")
text.set_text(' ')
if tval1 == -270 and tval3 == -150:
sprite.say(" ")
text.set_text(' ')
t1 = TestObjective()
t1.add_success((tval1== 90 or tval1 == -270) and tval3 == -150, "Great Job!")
t1.add_failure(tval1 == 0, "Try using a rotation to map your start triangle onto the target!")
t1.add_failure(tval1 == "DNE", "Try again!")
t1.add_failure((tval1 != 90 and tval1 != -270) and tval1 != 0, "That's not quite it. Try a different angle in your roation command!")
tester = TestManager()
tester.display_graphics = False
tester.add_test_list([t1])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)